﻿using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
using NewLife.Log;

namespace BingZi.HY.Core
{
 

    /// <summary>
    ///初始化数据
    /// </summary>
    public partial class sys_UserTable<TEntity>
    {
        #region 数据
        /// <summary>
        /// 首次连接数据库时初始化数据，仅用于实体类重载，用户不应该调用该方法
        /// </summary>
        [EditorBrowsable(EditorBrowsableState.Never)]
        protected override void InitData()
        {

            base.InitData();

            if (Meta.Count > 0) return;

            if (XTrace.Debug) XTrace.WriteLine("开始初始化{0}用户管理数据……", typeof(TEntity).Name);



            Meta.BeginTrans();
            try
            {
                //insert sys_User(UserID,U_LoginName,U_Password,U_CName,U_EName,U_GroupID,U_Email,U_Type,U_Status,U_Licence,U_Mac,U_Remark,U_IDCard,U_Sex,U_BirthDay,U_MobileNo,U_UserNO,U_WorkStartDate,U_WorkEndDate,U_CompanyMail,U_Title,U_Extension,U_HomeTel,U_PhotoUrl,U_DateTime,U_LastIP,U_LastDateTime,U_ExtendField) 
                //values(	1	,	N'admin'	,	'21232F297A57A5A743894A0E4A801FC3'	,	N'管理员'	,	''	,	0	,	''	,	0	,	0	,	''	,	''	,	N''	,	''	,	0	,	'2007-06-23 00:00:00.000'	,	''	,	''	,	'2007-06-23 00:00:00.000'	,	'2007-06-23 15:32:19.263'	,	''	,	17	,	''	,	''	,	N''	,	'2007-06-23 15:32:19.263'	,	''	,	'2007-06-23 15:32:19.263'	,'1,10')
                TEntity entity = new TEntity();
                entity.U_LoginName = "zzmzaizai";
                entity.U_Password = "21232F297A57A5A743894A0E4A801FC3";
                entity.U_ExtendField = "1,10";
                entity.U_DateTime = DateTime.Now;
                entity.U_Email = "zzmzaizai@msn.com";
                entity.U_EmailState = 1;
                entity.U_LastDateTime = DateTime.Now;
                entity.U_LastIP = "127.0.0.1";
                entity.U_Status = 0;
                entity.U_Type = 0;
              
                
                entity.Save();

                Meta.Commit();
            }
            catch (Exception ex)
            {
                if (XTrace.Debug) XTrace.WriteLine("初始化{0}用户管理数据失败,具体原因:{1}", typeof(TEntity).Name, ex.Message);
                Meta.Rollback(); throw;
            }

            if (XTrace.Debug) XTrace.WriteLine("完成初始化{0}用户管理数据！", typeof(TEntity).Name);
        }
        #endregion
    }
}
